home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Prog / Q-R / QDPat.cpt / HandleTheMenus.Pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1990-01-08  |  5.3 KB  |  201 lines  |  [TEXT/PJMM]

  1. unit HandleTheMenus;
  2.  
  3. {File name :  HandleTheMenus.Pas  }
  4. {Function: Handle all menu selections.}
  5. {          This procedure is called when a menu item is selected.}
  6. {          There is one CASE statement for all Lists.  There is}
  7. {          another CASE for all the commands in each List.}
  8. {History: 10/6/89 Original by Prototyper.   }
  9. {                       }
  10.  
  11. interface
  12.  
  13.     uses
  14.         Dialog_2, Dialog_1, Globals, InitTheMenus, Utilities, MenuUtilities;
  15.  
  16.     procedure Handle_My_Menu (var doneFlag: boolean; theMenu, theItem: integer; var theInput: TEHandle);{Handle menu selection}
  17.  
  18. implementation
  19.  
  20.     procedure Handle_My_Menu;           {Handle menu selections realtime}
  21.         const
  22.             L_Apple = 1001;             {Menu list}
  23.             C_About = 1;
  24.             L_File = 1002;              {Menu list}
  25.             C_Open = 1;
  26.             C_Close = 3;
  27.             C_Save = 4;
  28.             C_Save_As = 5;
  29.             C_Page_Setup = 7;
  30.             C_Print = 8;
  31.             C_Quit = 10;
  32.             L_Edit = 1003;              {Menu list}
  33.             C_Cut = 1;
  34.             C_Copy = 2;
  35.             C_Paste = 3;
  36.             C_Clear = 4;
  37.             L_Shapes = 1004;            {Menu list}
  38.             C_Rectangle = 1;
  39.             C_Square = 2;
  40.             C_Circle = 3;
  41.             C_Triangle = 4;
  42.         var
  43.             DNA: integer;              {For opening DAs}
  44.             BoolHolder: boolean;       {For SystemEdit result}
  45.             DAName: Str255;            {For getting DA name}
  46.             SavePort: GrafPtr;         {Save current port when opening DAs}
  47.  
  48.     begin                           {Start of procedure}
  49.  
  50.         case theMenu of         {Do selected menu list}
  51.  
  52.             L_Apple: 
  53.                 begin
  54.                     case theItem of{Handle all commands in this menu list}
  55.                         C_About: 
  56.                             begin
  57.                                 D_Dialog_2;{Call a dialog for this menu selection}
  58.                                 ResetWindow;
  59.                             end;
  60.                         otherwise       {Handle the DAs}
  61.                             begin           {Start of Otherwise}
  62.                                 GetPort(SavePort);{Save the current port}
  63.                                 GetItem(AppleMenu, theItem, DAName);{Get the name of the DA selected}
  64.                                 EnableItem(M_File, 1);
  65.                                 EnableItem(M_File, 3);
  66.                                 EnableItem(M_File, 4);
  67.                                 EnableItem(M_File, 5);
  68.                                 EnableItem(M_File, 7);
  69.                                 EnableItem(M_File, 8);
  70.                                 EnableItem(M_Edit, 1);
  71.                                 EnableItem(M_Edit, 2);
  72.                                 EnableItem(M_Edit, 3);
  73.                                 EnableItem(M_Edit, 4);
  74.                                 NotInDA := false;
  75.                                 DNA := OpenDeskAcc(DAName);{Open the DA selected}
  76.                                 SetPort(SavePort);{Restore to the saved port}
  77.                             end;            {End of Otherwise}
  78.  
  79.                     end;                {End of item case}
  80.                 end;                    {End for this list}
  81.  
  82.             L_File: 
  83.                 begin
  84.                     case theItem of{Handle all commands in this menu list}
  85.                         C_Open: 
  86.                             begin
  87.                             {?? ADD IN HERE WHAT THIS COMMAND SHOULD DO}
  88.                             end;
  89.                         C_Close: 
  90.                             begin
  91.                             {?? ADD IN HERE WHAT THIS COMMAND SHOULD DO}
  92.                             end;
  93.                         C_Save: 
  94.                             begin
  95.                             {?? ADD IN HERE WHAT THIS COMMAND SHOULD DO}
  96.                             end;
  97.                         C_Save_As: 
  98.                             begin
  99.                             {?? ADD IN HERE WHAT THIS COMMAND SHOULD DO}
  100.                             end;
  101.                         C_Page_Setup: 
  102.                             begin
  103.                             {?? ADD IN HERE WHAT THIS COMMAND SHOULD DO}
  104.                             end;
  105.                         C_Print: 
  106.                             begin
  107.                             {?? ADD IN HERE WHAT THIS COMMAND SHOULD DO}
  108.                             end;
  109.                         C_Quit: 
  110.                             begin
  111.                                 doneFlag := TRUE;
  112.                             end;
  113.                         otherwise
  114.                             begin           {Start of the Otherwise}
  115.                             end;            {End of Otherwise}
  116.  
  117.                     end;                {End of item case}
  118.                 end;                    {End for this list}
  119.  
  120.             L_Edit: 
  121.                 begin
  122.                     BoolHolder := SystemEdit(theItem - 1);{Let the DA do the edit to itself}
  123.                     if not (BoolHolder) then{If not a DA then we get it}
  124.                         begin               {Handle by using a Case statment}
  125.                             case theItem of{Handle all commands in this menu list}
  126.                                 C_Cut: 
  127.                                     begin
  128.                                 {?? ADD IN HERE WHAT THIS COMMAND SHOULD DO}
  129.                                     end;
  130.                                 C_Copy: 
  131.                                     begin
  132.                                 {?? ADD IN HERE WHAT THIS COMMAND SHOULD DO}
  133.                                     end;
  134.                                 C_Paste: 
  135.                                     begin
  136.                                 {?? ADD IN HERE WHAT THIS COMMAND SHOULD DO}
  137.                                     end;
  138.                                 C_Clear: 
  139.                                     begin
  140.                                 {?? ADD IN HERE WHAT THIS COMMAND SHOULD DO}
  141.                                     end;
  142.                                 otherwise{Send to a DA}
  143.                                     begin       {Start of the Otherwise}
  144.                                     end;        {End of Otherwise}
  145.  
  146.                             end;                {End of not BoolHolder}
  147.                         end;                {End of item case}
  148.                 end;                    {End for this list}
  149.  
  150.             L_Shapes: 
  151.                 begin
  152.                     case theItem of{Handle all commands in this menu list}
  153.                         C_Rectangle: 
  154.                             begin
  155.                                 UncheckMenus;
  156.                                 CheckItem(M_Shapes, 1, true);
  157.                                 WhichShape := Rectangle;
  158.                                 DrawShapes(Rectangle);
  159.                             {?? ADD IN HERE WHAT THIS COMMAND SHOULD DO}
  160.                             end;
  161.                         C_Square: 
  162.                             begin
  163.                                 UncheckMenus;
  164.                                 CheckItem(M_Shapes, 2, true);
  165.                                 WhichShape := Square;
  166.                                 DrawShapes(Square);
  167.                             {?? ADD IN HERE WHAT THIS COMMAND SHOULD DO}
  168.                             end;
  169.                         C_Circle: 
  170.                             begin
  171.                                 UncheckMenus;
  172.                                 CheckItem(M_Shapes, 3, true);
  173.                                 WhichShape := Circle;
  174.                                 DrawShapes(Circle);
  175.                             {?? ADD IN HERE WHAT THIS COMMAND SHOULD DO}
  176.                             end;
  177.                         C_Triangle: 
  178.                             begin
  179.                                 UncheckMenus;
  180.                                 CheckItem(M_Shapes, 4, true);
  181.                                 WhichShape := Triangle;
  182.                                 DrawShapes(Triangle);
  183.                             {?? ADD IN HERE WHAT THIS COMMAND SHOULD DO}
  184.                             end;
  185.                         otherwise
  186.                             begin           {Start of the Otherwise}
  187.                             end;            {End of Otherwise}
  188.  
  189.                     end;                {End of item case}
  190.                 end;                    {End for this list}
  191.  
  192.             otherwise
  193.                 begin                   {Start of the Otherwise}
  194.                 end;                    {End of Otherwise}
  195.  
  196.         end;                        {End for the Lists}
  197.  
  198.         HiliteMenu(0);              {Turn menu selection off}
  199.     end;                            {End of procedure Handle_My_Menu}
  200.  
  201. end.                                    {End of unit}